home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / akcl1615.lha / c / init_pari.c < prev    next >
C/C++ Source or Header  |  1991-04-08  |  2KB  |  80 lines

  1. #define IN_INIT_PARI
  2.  
  3. #ifndef STANDALONE
  4. #include "include.h"
  5. #endif
  6. #include "genpari.h"  
  7.  
  8.  
  9. GEN     gnil,gzero,gun,gdeux,ghalf,polvar,gi,RAVYZARC;
  10. long    lontyp[30]={0,0x10000,0x10000,1,1,1,1,2,1,0,2,2,1,1,1,0,1,1,1,1};
  11. unsigned long hiremainder,overflow;
  12.  
  13. #ifdef STANDALONE
  14. #define FEerror printf
  15. #define make_si_sfun(a,b,c) 
  16. #endif
  17.  
  18. #define INITIAL_PARI_STACK 400
  19. char initial_pari_stack[400];
  20.  
  21. ulong bot= (ulong) initial_pari_stack;
  22. ulong top = (ulong)(initial_pari_stack+INITIAL_PARI_STACK);
  23. /* not initted */
  24. ulong avma= 0;
  25.  
  26.  
  27. void
  28. err(s)
  29.      int s;
  30. { if (s==errpile)
  31.   FEerror("Out of bignum stack space, (si::MULTIPLY-BIGNUM-STACK n) to grow");
  32.   else
  33.       FEerror("bignum error");
  34. }
  35.  
  36.  
  37.  
  38.  
  39. multiply_bignum_stack(n)
  40.      int n;
  41. { int parisize = n* (top - bot);
  42.   in_saved_avma = 0;
  43.   if (n> 1) 
  44.     { if (bot != (ulong)initial_pari_stack) free(bot);
  45.       set_pari_stack(parisize);
  46.     }
  47.   return parisize;
  48. }
  49.   
  50. set_pari_stack(parisize)
  51.      int parisize;
  52. {
  53.   bot=(long)malloc(parisize);
  54.   top = avma = bot + parisize;
  55. }
  56.  
  57.  
  58. init_pari()
  59. {
  60.   if (avma==0)
  61.     { 
  62.     make_si_sfun("MULTIPLY-BIGNUM-STACK",multiply_bignum_stack,
  63.              ARGTYPE1(f_fixnum) | RESTYPE(f_fixnum));
  64.     avma = top;
  65.       }
  66.  /* room for the permanent things */
  67.  
  68.   gnil = cgeti(2);gnil[1]=2; setpere(gnil,255);
  69.   gzero = cgeti(2);gzero[1]=2; setpere(gzero, 255);
  70.   gun = stoi(1); setpere(gun, 255);
  71.   gdeux = stoi(2); setpere(gdeux, 255);
  72.   ghalf = cgetg(3,4);ghalf[1]=un;ghalf[2]=deux; setpere(ghalf, 255);
  73.   gi = cgetg(3,6); gi[1] = zero; gi[2] = un; setpere(gi, 255);
  74.  
  75.   /* set_pari_stack(BIGNUM_STACK_SIZE);*/
  76.  }
  77.  
  78.  
  79.  
  80.